package Engine;

import org.lwjgl.Sys;
import org.lwjgl.opengl.Display;


/**
 * Write a description of class Time here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class Time
{
	
	private long lastFPS;
	private long lastFrame;
	public int fps;
	public double delta;
	public Time()
	{
		lastFPS = getTime(); 
	}
	
	/**
     * Gibt die Zeit in millisekunden
     * 
     * @return The system time in milliseconds
     */
    public long getTime() {
    	return (Sys.getTime()*1000) / Sys.getTimerResolution();
    }
    public double getDelta() {
    	return delta;
    }
    
    public double getFps(){
    	return currentfps;
    }
    
    double currentfps;
    public void updateFPS() {
    	if(lastFrame==0){
    		lastFrame = getTime();
    	}
    	delta =  (double)(getTime() - lastFrame)/100d;
    	lastFrame = getTime();
        if (getTime() - lastFPS > 1000) {
        	currentfps = fps;
            fps = 0; //reset the FPS counter
            lastFPS += 1000; //add one second
        }
        fps++;
    }
    

  
}
